home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / mus / play / tracker_4_31.lzh / tracker / Docs / protracker.fmt < prev    next >
Text File  |  1995-05-11  |  12KB  |  304 lines

  1. File format
  2. -----------
  3.  
  4. Offset
  5. ---------------------------------------
  6.   0          20 bytes            Song Name (9)
  7.  
  8.  20         22 bytes            Sample name
  9.  42           1 word            sample length (2)
  10.  43            1 byte            finetune (3)
  11.  44           1 byte            volume (4)
  12.  46           1 word            looping start point
  13.  48           1 word            looping length
  14.               ---------
  15.              30 bytes (1)
  16.  
  17. 20+30*n       1 byte            length of song (5)
  18. 21+30*n       1 byte            number of patterns to load (6)
  19. 22+30*n   128 bytes            pattern indices (7)
  20.  
  21. 1080           4 bytes            signature (31 samples modules only)
  22.  
  23. 150+30*n 1024 bytes           each pattern (10)
  24.  
  25. 150+30*n                   sample data (8)
  26. +1024*p
  27.  
  28. Notes
  29. -----
  30. (1) There are 15 sample info entries in old soundtracker files, 31 in newer
  31. protracker/noisetracker ones. The difference lies in the signature.
  32. Valid signatures are M.K. / M!K! (for Mahoney & Kaktus), FLT4/FLT8 for 
  33. startrekker modules.
  34. (2) Sample length, looping start point, looping length is normally stored
  35. as a number of words. Occasionally, in very old modules, the looping start
  36. point might be stored in bytes (case in point: kawai-k1). Checking
  37. looping start point + looping length against sample length might discover
  38. the problem.
  39. (3) Finetune does only exist for protracker modules: if the signature isn't
  40. M.K./M!K!, it should be 0. Normal values are 0-15. See below for a discussion
  41. of finetunes. Signature M!K! should only occur if the number of patterns is
  42. greater than 64.
  43. (4) This is the sample default volume, when no specific values have been
  44. given. Normal values are 0-64. Some songs include out of range values.
  45. (5) Range 1-128
  46. (6) Do not trust this byte ! Very old trackers used it to indicate the number
  47. of pattern indices, so it's set to 127 by protracker to enable old trackers
  48. to load this module. Noisetracker uses this byte for restart.
  49. (7) This is a sequencing order: like in play pattern #2, then #4, then #2
  50. again, and so on...
  51. (8) Sample data is given for each existing sample. Non-existing samples have
  52. a length of 0 or 1 (usually 1).
  53. - sample values are signed bytes, in 2-complement notation. Each sample length
  54. is a multiple of 2 in bytes.
  55. (9) Song names and sample names will be converted to a null-terminated string.
  56. Be very careful as to what to allow there...
  57. (10) We use the highest pattern number in the pattern indices table to
  58. determine the number of patterns p to load. Older trackers saved it as
  59. `number of patterns to load'.
  60.  
  61. Decoding pattern info
  62. ---------------------
  63. Each pattern holds 64 sets of 4 events, one for each amiga track, numbered 
  64. 0 to 3 in the usual amiga way (0-3: left channels, 1-2: right channels).
  65. The four bytes per event are to be decoded as follows:
  66.  
  67.  _____byte 1_____   byte2_    _____byte 3_____   byte4_
  68. /                \ /      \  /                \ /      \
  69. 0000          0000-00000000  0000          0000-00000000
  70.  
  71. Upper four    12 bits for    Lower four    Effect/parameters
  72. bits of sam-  note period.   bits of sam-
  73. ple number.                  ple number.
  74.  
  75. Sample number should be in the range 0-31... anything else is an error, and
  76. should be flagged as such. 
  77. For standard protracker modules, the note period can be converted to a note n
  78. with the following lookup table:
  79.   C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453
  80.   C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226
  81.   C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113
  82. older tracker modules may use highly non-standard periods.
  83. These pitch values ARE amiga-dependent. See appendix for further details.
  84.  
  85. The effect command has two parts:
  86. an effect and parameters. You should actually decode it as three independent
  87. nibble: e (effect) phi (parameter, hi-part), plow (parameter, low-part).
  88. The interpretation is very dependent of the actual command involved. In many
  89. cases, phi and plow are read as a single byte parameter (para=phi<<4 | plow)
  90.  
  91. About tempo
  92. -----------
  93. The player uses two tempo values: fundamental tempo (t1) and fine tempo (t2,
  94. invention of protracker).
  95. By default, t1=6 and t2=125.
  96. A tick occurs with a frequency of 50*t2/125 Hz (some specific tracker tunes
  97. have been developped on NTSC machines with a buggy tracker and the frequency
  98. is 60*t2/125 Hz in that case).
  99.  
  100. The basic play-sequence takes t1 ticks:
  101. 0st tick: read new series of event and applies them. Do NOT apply on-going
  102. effects (violent contrast with MED).
  103. 1nd to t1-1th ticks: apply effects.
  104. then start again.
  105.  
  106. About finetunes
  107. ---------------
  108. Finetune is a weird invention of protracker. Since it is used very often,
  109. we can't avoid it.
  110.  
  111. It must be decoded as follows:
  112. Value:    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  113. Finetune: 0 +1 +2 +3 +4 +5 +6 +7 -8 -7 -6 -5 -4 -3 -2 -1
  114.  
  115. (this is actually two-complement value, but over a nibble, which is
  116. a bit unusual). 
  117. Its interpretation is as follows: an instrument with a current finetune of f
  118. should be played offset by f/8 halftones up.
  119. In the end, to find the correct pitch to play a note at, you take the note 
  120. period AS STORED IN THE TABLE WITH f=0, convert it to a note value, and then
  121. offset it to finetune f, compute the correct pitch [look it up] and play the
  122. note. Loading a sample (as in sample number != 0) will obviously update the
  123. finetune for the corresponding channel. There is also an extended command to
  124. change a sample finetune without loading a new sample (see module crystal_rain
  125. for instance).
  126.  
  127. About sample numbers and note periods
  128. -------------------------------------
  129. There has to exist a separate automaton for each of the four (eight ?) channels
  130. of a protracker song. To have a sample number != 0 means to load
  131. a number of parameters from the sample information:
  132. - its default volume (special case: volume command)
  133. - its finetune (special case: extended finetune command)
  134. Likewise, to have a note period !=0 means to change the note period 
  135. immediately, except for the tone portamento and portamento-slide commands.
  136.  
  137. Effects
  138. -------
  139. 0 Arpeggio/No effect
  140. if phi == 0 and plow == 0, the note sounds normal
  141. else, the pitch changes at each tick, cycling through notes n, n+phi, n+plow
  142. at each tick (phi and plow in half-tones up) (in this order)
  143. (previous portamento effects will be forgotten, since a note value is needed)
  144.  
  145. 1 Portamento up
  146. slide the note pitch up from the current pitch at the rate of para each tick.
  147. There normally is an upper boundary of B-3/pitch 113.
  148.  
  149. 2 Portamento down
  150. slide the note pitch down from the currenty pitch at the rate of para each tick.
  151. There normally is a lower boundary of C-1/pitch 856.
  152.  
  153. 3 Tone portamento
  154. slide the note pitch from the current pitch to the note pitch at the rate
  155. of para each tick. You can keep on sliding without having to specify a new
  156. para nor note. 
  157. The goal is reset to 0 when reached, so if you reach the note, no tone
  158. portamento without a goal will have an effect.
  159.  
  160.  
  161. 4 Vibrato
  162. phi is the speed of the vibrato and plow the depth of the vibrato.
  163. values of 0 for phi or plow just mean to keep the previous rate.
  164.  
  165. the basic vibrato waveform is a sine waveform.
  166. It can be changed to square, or rampdown.
  167.  
  168. Here are the actual shapes used, with origin et all.
  169.  
  170.  
  171.  
  172.     ****                     ********                     **
  173.   **    **                                              **
  174.  *        *                                           **
  175. *          *                                        **       
  176.             *        *                                          **
  177.                  **    **                                         **
  178.                    ****                  *******                **
  179.  
  180.     Sine 0                     Square 1                Rampdown 2
  181. (see extended 4 for a detailled discussion of some aspects of that effect)
  182.  
  183. The resulting waveform has an amplitude of 2*depth, e.g., its values are in 
  184. the range [-2*depth, 2*depth], and its full period is 64/speed ticks.
  185.  
  186. The position in the waveform is reset at each and every new note on the 
  187. channel.
  188.  
  189.  
  190. 5 Tone-portamento + Volume slide
  191. Continue the current tone portamento while applying volume slide.
  192. The parameters are used for the volume slide. The tone portamento parameters
  193. currently in effect still apply.
  194.  
  195. 6 Vibrato + volume slide
  196. Exactly like command 5.
  197.  
  198. 7 Tremolo
  199. just like vibrato except it affects the volume instead of the pitch.
  200. Note that the amplitude is TWICE that of vibrato as per protracker 1.1 source.
  201. Also note that there is a range check since volume must stay in 0,64 range.
  202.  
  203. 9 Set Sample offset
  204. play the sample from an offset instead of from the start. The offset (in bytes)
  205. is para * 256. If para is null, we use the last para instead.
  206. If offset exceeds the sample length, just play a null sample
  207.  
  208. 10 Slide volume
  209. if (phi !=0 ) slide the volume up by phi each tick,
  210. else slide the volume down by plow each tick.
  211. Note: phi and plow can be zero, there will simply be no volume change.
  212. Working order: check that sample 7 is heard correctly in ghouls.
  213.  
  214. 11 Far jump/Position jump
  215. The next events will be read from pattern index para instead of
  216. the normal position. para has the normal range 0-127... protracker
  217. code can be confusing since it is somewhat confused and intricate there.
  218.  
  219. 12 Set volume/Volume change
  220. Set volume for the associated channel to para. 
  221.  
  222. 13 Small jump/Pattern break
  223. The next events will be read from the next pattern starting at
  224. position phi*10+plow instead of 0. (for strange reasons, we have a BCD value
  225. here). Values >=64 are reduced to 0 !
  226.  
  227. 14 Extended command
  228. phi is interpreted as a secondary command number. See below.
  229. So the parameter is actually plow for these commands.
  230.  
  231. 15 Set speed
  232. if 0 <= para <= 31, set t1=para, reset t2 to 125. 
  233. Else, set t2=para (for protracker).
  234. Older trackers don't ever change t2, but always set t1=para.
  235. Special value 0 is supposed to end the module with protracker.
  236. special case: several set speed commands in the same events. The later ones
  237. do take precedence upon the earlier ones if both are supposed to affect t1
  238. or t2. If one set speed command affects t1 and the other t2, the most likely
  239. guess is to set t1 and t2 accordingly, but you CAN'T be sure... you have to
  240. either provide some switch to change your player behavior according to the
  241. value you got, or to apply some heuristic to go on playing...
  242.  
  243. Extended commands:
  244. -----------------
  245. 14-0 Set filter    [not implemented in tracker]
  246. change the state of the amiga low-pass filter 
  247.  
  248. 14-1 fine portamento up
  249. like portamento up, except it occurs only at the first tick, this means the
  250. time the command is interpreted, not later as for portamento up.
  251.  
  252. 14-2 fine portamento down
  253.  
  254.  
  255. 14-3 glissando control 
  256. If set (para != 0), following tone portamentos will round each value to the
  257. nearest entire note.
  258.  
  259. 14-4 set vibrato waveform 
  260. Acceptable range is 0-3: 0 is the default sine, 1 the square, and 2 the
  261. rampdown. Protracker docs speak of 3 being a random waveform, but I've
  262. yet to see it implemented ! Neither pt1-1, pt1-2, pt2-0 implement it.
  263. You're supposed to add 4 to control whether the viboffset is reset at 
  264. each note (if 4, not reset, but this looks buggy as hell to me...)
  265.  
  266. 14-5 set finetune
  267. set finetune for the current channel to the para value right away, instead of 
  268. the current sample finetune.
  269.  
  270. 14-6 Loop pattern
  271. if para == 0, set start of loop, else loop to loop start para+1 times before
  272. playing on.
  273. This effect is channel-dependent, so you can use several channels and 
  274. interleave loops... 
  275.  
  276. 14-7 set tremolo waveform 
  277. Like set vibrato waveform.
  278.  
  279. 14-8 Reserved for future extensions
  280.  
  281. 14-9 Retrig note
  282. retrig note on para-th, 2para-th,... tick.
  283.  
  284. 14-10 fine volume slide up
  285. like volume up, except it occurs only once on the first tick
  286.  
  287. 14-11 fine volume slide down
  288.  
  289. 14-12 cut note
  290. set volume of current note to 0 on para-th tick
  291.  
  292. 14-13 delay note
  293. start note on para-th tick instead of now.
  294.  
  295. 14-14 delay pattern
  296. wait for para * speed ticks before processing new entries.
  297. Note that effects do proceed as usual, except that they DON'T
  298. occur once every speed-th tick (the event change is inhibited)
  299. Delay pattern is a global effect.
  300.  
  301. 14-15 invert loop 
  302. see code for that weird effect.
  303.  
  304.